/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
 *
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * OpenSceneGraph Public License for more details.
*/

#include <osgGe/Math>

#include <osgGe/Vec2d>

#include <osgGe/Vec2f>
#include <osgGe/Vec3d>

#include <osgGe/Vec4d>

#include <osgGe/Vec4f>

#include <osgGe/Matrixd>

#include <osgGe/Matrixf>

using namespace osg;
using namespace osgGe;

bool Vec2d::isNaN() const
{
	return osg::isNaN(_v[0]) || osg::isNaN(_v[1]);
}

bool Vec2d::valid() const 
{ 
	return !isNaN(); 
}




 bool Vec2f::isNaN() const
 {
	 return osg::isNaN(_v[0]) || osg::isNaN(_v[1]);
 }
 bool Vec2f::valid() const 
 {
	 return !isNaN(); 
 }


  /** Returns true if at least one component has value NaN. */
  bool Vec3d::isNaN() const
  {
	  return osg::isNaN(_v[0]) || osg::isNaN(_v[1]) || osg::isNaN(_v[2]);
  }
  /** Returns true if all components have values that are not NaN. */
   bool Vec3d::valid() const
  { 
	  return !isNaN();
  }


   /** Returns true if at least one component has value NaN. */
   bool Vec4d::isNaN() const
   {
	   return osg::isNaN(_v[0]) || osg::isNaN(_v[1]) || osg::isNaN(_v[2]) || osg::isNaN(_v[3]);
   }

  bool Vec4d::valid() const
  {
	  return !isNaN(); 
  }


   bool Vec4f::isNaN() const
   {
	   return osg::isNaN(_v[0]) || osg::isNaN(_v[1]) || osg::isNaN(_v[2]) || osg::isNaN(_v[3]);
   }
   bool Vec4f::valid() const
   {
	   return !isNaN();
   }

   Vec4f::value_type& Vec4f::x() { return _v[0]; }
   Vec4f::value_type& Vec4f::y() { return _v[1]; }
   Vec4f::value_type& Vec4f::z() { return _v[2]; }
   Vec4f::value_type& Vec4f::w() { return _v[3]; }

   Vec4f::value_type Vec4f::x() const { return _v[0]; }
   Vec4f::value_type Vec4f::y() const { return _v[1]; }
   Vec4f::value_type Vec4f::z() const { return _v[2]; }
   Vec4f::value_type Vec4f::w() const { return _v[3]; }

   Vec4d::value_type& Vec4d::x() { return _v[0]; }
   Vec4d::value_type& Vec4d::y() { return _v[1]; }
   Vec4d::value_type& Vec4d::z() { return _v[2]; }
   Vec4d::value_type& Vec4d::w() { return _v[3]; }

   Vec4d::value_type Vec4d::x() const { return _v[0]; }
   Vec4d::value_type Vec4d::y() const { return _v[1]; }
   Vec4d::value_type Vec4d::z() const { return _v[2]; }
   Vec4d::value_type Vec4d::w() const { return _v[3]; }


    bool Matrixd::isNaN() const 
	{
		return osg::isNaN(_mat[0][0]) || osg::isNaN(_mat[0][1]) || osg::isNaN(_mat[0][2]) || osg::isNaN(_mat[0][3]) ||
		   osg::isNaN(_mat[1][0]) || osg::isNaN(_mat[1][1]) || osg::isNaN(_mat[1][2]) || osg::isNaN(_mat[1][3]) ||
		   osg::isNaN(_mat[2][0]) || osg::isNaN(_mat[2][1]) || osg::isNaN(_mat[2][2]) || osg::isNaN(_mat[2][3]) ||
		   osg::isNaN(_mat[3][0]) || osg::isNaN(_mat[3][1]) || osg::isNaN(_mat[3][2]) || osg::isNaN(_mat[3][3]);
   }


	 bool Matrixf::isNaN() const 
	 {
		return osg::isNaN(_mat[0][0]) || osg::isNaN(_mat[0][1]) || osg::isNaN(_mat[0][2]) || osg::isNaN(_mat[0][3]) ||
			osg::isNaN(_mat[1][0]) || osg::isNaN(_mat[1][1]) || osg::isNaN(_mat[1][2]) || osg::isNaN(_mat[1][3]) ||
			osg::isNaN(_mat[2][0]) || osg::isNaN(_mat[2][1]) || osg::isNaN(_mat[2][2]) || osg::isNaN(_mat[2][3]) ||
			osg::isNaN(_mat[3][0]) || osg::isNaN(_mat[3][1]) || osg::isNaN(_mat[3][2]) || osg::isNaN(_mat[3][3]);
	}